/*
 *  消消乐的节点
 * 
 */
class XXLNode
{
    // x坐标
    public get x_pos(){ return this._x_pos;}
    public set x_pos(num : number){ this._x_pos = num;}
    // y坐标
    public get y_pos(){ return this._y_pos; }
    public set y_pos(num : number){ this._y_pos = num;}
    // 单一坐标
    public get k_pos(){ return this._k_pos; }
    // 节点值(通过值读表得到图片名)
    public get val(){ return this._val; }
    public set val(num : number){ 
        this._val = num; 
        this.getColor();
    }
    // 爆炸类型
    public get blast_type(){ return this._blast_type; }
    // 存在状态(1: 存在 0: 不存在)
    public get state(){ return this._state; }
    public set state(num : number){ this._state = num; }
    // 是否可以消除
    public get canXC(){ return this._canXC; }

    public get color(){ return this._color; }

    public constructor(xPos, yPos, val)
    {
        let self = this;

        self._x_pos = xPos;
        self._y_pos = yPos;
        self._val = val;
        self._blast_type = 0;
        self._state = 1;
        self._color = "無";
        self.getColor();
    }

    public setCanXC(){
        this._canXC = true;
    }

    public clone(node:XXLNode){
        let self = this;

        let state = node._state;
        let val = node._val;
        let blast = node._blast_type;

        node._state = self._state;
        node._val = self._val;
        node._blast_type = self._blast_type;

        self._state = state;
        self._val = val;
        self._blast_type = blast;

        self.getColor();
    }

    public swapePos(node:XXLNode){
        if(node == null) return;
        let self = this;

        let x = node.x_pos;
        let y = node.y_pos;

        node._x_pos = self._x_pos;
        node._y_pos = self._y_pos;

        self._x_pos = x;
        self._y_pos = y;

        self.getColor();
    }

    // 消除自身
    public xcSelf()
    {
        let self = this;

        self._val = -1;
        self._state = 0;
        self._canXC = false;
        self._blast_type = -1;        
    }

    public _color : string;
    private getColor(){
        let self = this;
        switch(self._val){
            case 1:
                self._color = "红";
                break;
            case 2:
                self._color = "棕";
                break;
            case 3:
                self._color = "黄";
                break;
            case 4:
                self._color = "绿";
                break;
            case 5:
                self._color = "蓝";
                break;
            case 6:
                self._color = "紫";
                break;
            case 7:
                self._color = "白";
                break;
        }
    }

    // x坐标
    private _x_pos : number;
    // y坐标
    private _y_pos : number;
    // 单一坐标
    private _k_pos : number;
    // 节点值(通过值读表得到图片名)
    private _val : number;
    // 爆炸类型
    private _blast_type : number;
    // 存在状态(1: 存在 0: 不存在)
    private _state : number;
    // 是否可以消除
    private _canXC : boolean;
}